﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm2.aspx.cs" Inherits="PageUnloadNotifier.WebForm2" %>
<%@ Register TagPrefix="ctrl" TagName="PageUnloadNotifier" Src="~/PageUnloadNotifier.ascx" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
     <script type="text/javascript" src="<%= ResolveClientUrl("~/scripts/jquery-1.5.1.min.js") %>"></script>
    <script type="text/javascript">
        function PageOnUnload() {
            alert('execute something before actually leaving eg. saving WebForm2');
        }

    </script>
</head>
<body>
  <ctrl:PageUnloadNotifier ID="unloadPageNotifier" Message="going to leave from WebForm2" UnloadFunctionName="PageOnUnload" runat="server" />

    <form id="form1" runat="server">
    <div>
      <asp:LinkButton ID="LinkButton1" runat="server" OnClick="LinkButton2_Click">Go to webform 2(LinkButton doesn't work well)</asp:LinkButton>
        <br />
        <asp:HyperLink ID="HyperLink1" runat="server" NavigateUrl="~/WebForm2.aspx">Go to webform2 (HyperLink works)</asp:HyperLink>
    </div>
    </form>
</body>
</html>
